package exampleone.behavior;

import gamehandlers.GameHandler;
import sprite.Sprite;
import spritebehavior.Behavior;
import utility.Bounce;


/**
 * This is a sprite that simply moves in straight line and bounces when hits
 * something.
 * 
 * @author Yaqi Zhang
 * 
 */
public class SimpleMoveBehavior implements Behavior {

    private Sprite mySprite;
    private GameHandler myGameHandler;

    /**
     * 
     */
    public SimpleMoveBehavior () {
        // mySprite = sp;
    }

    /**
     * this sprite move in a straight line
     */
    public void move () {
        mySprite.getCenter().translate(mySprite.getVelocity().x,
                mySprite.getVelocity().y);
    }

    @Override
    public void update () {
        move();
        if (myGameHandler.isHitLeftRightWall(mySprite)) {
            Bounce.apply(mySprite, "Horizontally");
        }
        if (myGameHandler.isHitTopBottomWall(mySprite)) {
            Bounce.apply(mySprite, "Vertically");
        }
    }

    /**
     * sets the GameHandler
     * 
     * @param gh GameHandler
     */
    @Override
    public void setGameHandler (GameHandler gh) {
        myGameHandler = gh;
    }

}
